package com.totoro.mybatis.mul_datasource_dynamic.service.user;

import com.totoro.mybatis.mul_datasource_dynamic.aop.DS;
import com.totoro.mybatis.mul_datasource_dynamic.dao.user.UserDao;
import com.totoro.mybatis.mul_datasource_dynamic.domain.user.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Niki on 2018/8/16 9:52
 */
@Service
public class UserService {
    @Autowired
    UserDao userDao;

    @DS("db1")
    public int insert(User user) {
        userDao.insertUser(user);
        return user.getId();
    }

    @DS("db1")
    public User queryById(int id) {
        return userDao.queryById(id);
    }
}
